import React from 'react';
import { HeaderNav } from 'components';
import { Footer } from 'components';
import renderRoutes from 'libs/routes';
import createContext from 'libs/context';
import http from 'libs/http';

const { Provider } = createContext('authority', '');
export default class Login extends React.Component {
  state = {
    authority: ''
  }

  componentDidMount() {
    this.checkRoleType()
  }

  checkRoleType = () => {
    http.get('/role/getRole').then(res => {
      res.data && this.setState({
        authority: res.data
      })
    })
  }

  render() {
    const { authority } = this.state
    return (
      <div className="mid-container">
        <Provider value={{ authority }}>
          { renderRoutes('/introduce') }
        </Provider>
      </div>
    );
  }
}
